package com.sina.finance.paycenter.infrastructure.moduletoproj;

import com.cysyz.mylib.utils.MyFileUtils;
import com.cysyz.mylib.utils.ShellUtils;

import java.io.File;
import java.io.IOException;
import java.util.Map;
import java.util.Properties;

/**
 * @File name : ProjGenearator
 * @Description :
 * @Creator : cuiyong
 * @CreateTime : 16/3/10 16:58
 * @Version : 1.0
 * @Update records:
 * 1.0 16/3/10 by cuiyong: Created
 * All rights served : SINA Corporation
 */
public class ProjGenearator {
    public static void main(String[] args) throws IOException {
        String groupId = "com.sina.finance.paycenter.infrastructure.biz";

//        String artifactId = "waa";

        String moduleId = "account";

        String artifactId = System.getProperty("artifactId");
        //executeShell(groupId, artifactId);

        String targetMvnProjPath = artifactId + "/src/main/java/" + groupId.replaceAll("\\.", "/") + "/" + moduleId;

        MyFileUtils.copyDirectory(new File(moduleId), new File(targetMvnProjPath));
        Properties properties = System.getProperties();
        for (Map.Entry<Object, Object> objectObjectEntry : properties.entrySet()) {
            System.out.println(objectObjectEntry.getKey() + ";" + objectObjectEntry.getValue());
        }
    }

    private static void executeShell(String groupId, String artifactId) {
        ShellUtils.executeShell("mvn archetype:generate -DgroupId=" + groupId + " -DartifactId=" + artifactId + " -DpackageName=" + groupId + "\n" +
                " -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false -DarchetypeCatalog=internal");
    }



}
